<template>
<div>
    <div id="nav2" style="background-color: #fff;">
        <div class="title">
            <div class="navLogo">
                <img  src="../assets/images/知遇2.png" alt="">
            </div>
            <router-link tag="li" to="/Home" class="first"><span>首页</span></router-link>
            <router-link tag="li" to="/Blogs/total?sort=popular" class="first"><span>专栏</span></router-link>
            <router-link tag="li" to="/index/content" class="first"><span>社区</span></router-link>
            <router-link tag="li" to="/mainshow/bookshop" class="first"><span>书店</span></router-link>
            <router-link tag="li" to="/talk" class="first"><span>闲嗑</span></router-link>
            <router-link tag="li" to="/login" class="second " v-if='!navnone'><el-button type="primary" class="navlogin" >登录/注册</el-button></router-link>
            <router-link tag="li" to="/User" class="second" v-if='navnone'>
                <img :src="`http://localhost:3000/upload/${own.headImg}`" alt="">
            </router-link>
            <router-link tag="li" to="" class="second" v-if='navnone' >
                <svg t="1597729015370" @click="appear()" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7331" width="24" height="24"><path d="M876.266158 704.70146H882.692115a70.614907 70.614907 0 0 1 70.614906 70.614906v2.895212a70.614907 70.614907 0 0 1-70.614906 70.614906H141.235596a70.614907 70.614907 0 0 1-70.614906-70.614906v-2.895212a70.614907 70.614907 0 0 1 70.614906-70.614906h6.425957L153.24013 353.074533C156.36484 158.071468 316.960791 0 511.963856 0s355.599016 158.071468 358.706071 353.074533l5.596231 351.626927zM370.981195 865.032605h299.619048a150.056676 150.056676 0 1 1-299.601395 0z" p-id="7332" fill="#8a8a8a"></path></svg>
            </router-link>
            <router-link tag="li" to="" class="second">
                <div class="search-div">
                    <input type="text" placeholder="Search" v-model="searchval"  @keyup.enter="searchenter()"/>
                    <div class="search"></div>
                </div>
            </router-link>
           
        </div>
                 
    </div>
    <div id='quit' v-if='flag' @click="quits()">
                    <div class="quiticon"></div>
                    退出登录
                </div>
</div>
    
</template>
<script>
export default {
    data(){
        return{
            searchval:'',
            navnone:false,
            ownuids:'',
            own:'',
            flag:false
        }
    },
    created(){
        this.ownuids=this.$store.state.ownUid
        if(this.ownuids){
            this.navnone=!this.navnone
            this.$axios.get('http://localhost:3000/nav/img',{params:{uid:this.ownuids}})
                .then(res=>{
                    this.own=res.data.data[0]
                    console.log("我执行完成了")
                })
                .catch(err=>{
                console.log('err:',err)
            })
        }
    },
    methods: {
        searchenter(){
            this.$router.push({name: "searchs",query: {searchval:this.searchval}});
        },
        appear(){
            this.flag=!this.flag
        },
        quits(){
            this.$store.state.ownUid=null
            this.navnone=!this.navnone
            this.flag=!this.flag
        }
    }
}
</script>
<style>
    #quit{
        width: 100px;
        text-align: center;
        height: 40px;
        line-height: 20px;
        border-radius: 5px;
        box-sizing: border-box;
        background-color: #fff;
        position: absolute;
        top:75px;
        left:50%;
        margin-left: 440px;
        color:#aaa;
        box-shadow: 0 0 10px 0 rgba(0,0,0,0.2);
        z-index: 103;
        cursor: pointer;
        transition: .3s all;
    }
    #quit:hover{
        background-color: rgba(244,244,244);
    }
    #quit .quiticon{
        position: relative;
        top:-9px;
        left: 50px;
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-bottom: 10px solid white;
        z-index: 102;
    }
    #nav2{
    height: 60px;
    width: 100%;
    box-shadow:0px 2px 2px #ddd;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 100;
    /* background-image: linear-gradient( rgba(255, 255, 255, 1),rgba(2, 255,252,0.1)) url(/assets/images/001.jpeg); */
}
    #nav2 .navLogo{
        float: left;
        margin-right: 20px;
    }
    #nav2 .navLogo img{
        height: 80px;   
    }
    .title{
        width: 1200px;
        height:60px;
        position: relative;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        /* margin: auto auto; */
        /* padding-top: 20px; */
        /* background-color: white; */
    }
    .title li{
        position: relative;
        top:50%;
        transform: translateY(-50%);
        font-size: 18px;
        list-style: none;
        transition:border 0.25s;
        
    }
    .first{
        float: left;
        box-sizing: border-box;
        margin:0 30px;
        padding:10px 5px;
        font-family: microsoft yahei light,microsoft yahei,Helvetica,sans-serif,等线;
    }
    #nav2 .first ::after{
            content: "";
            position: absolute;
            bottom: -1px;
            left: -1px;
            right: -1px;
            top: -1px;
            transform:scale(0, 1);
            transition: all 0.3s;
            border-bottom: 2px solid rgb(67,149,255);
        }
    #nav2 .first:hover ::after{
        transform:scale(1);
        transition:all .3s;
    }

    #nav2 .second{
        float: right;
        margin: 0 20px;
        color:#555;
        font-weight: 500;
        letter-spacing: 0.1em;
        font-size: 16px;
        cursor: pointer;
    }
    #nav2 .navlogin{
        letter-spacing: .1em;
    }
    #nav2 .second img{
        height: 36px;
        width: 36px;
        border-radius: 6px;
    }
            .search-div {
                margin-right: 220px;
    position: relative;
    /* width: 300px; */
    /* height: 60px; */
}

.search-div .search {
    position: absolute;
    margin: auto;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 34px;
    height: 34px;
    background: rgb(81, 154, 250);
    border-radius: 50%;
    transition: all 1s;
    z-index: 4;
    box-shadow: 0 0 5px 0 rgba(78, 78, 78, 0.4);
}

.search-div .search:hover {
    cursor: pointer;
}


/* 放大镜斜杠 */

.search-div .search::before {
    content: "";
    position: absolute;
    margin: auto;
    top: 15px;
    right: 0;
    bottom: 0;
    left: 15px;
    width: 8px;
    height: 2px;
    background: white;
    transform: rotate(45deg);
    transition: all .5s;
}


/* 放大镜圆圈 */

.search-div .search::after {
    content: "";
    position: absolute;
    margin: auto;
    top: -4px;
    right: 0;
    bottom: 0;
    left: -4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    transition: all .5s;
}

.search-div input {
    /* font-family: '黑体'; */
    position: absolute;
    margin: auto;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 34px;
    height: 34px;
    outline: none;
    border: none;
    padding: 10px 20px;
    background:rgb(255, 255, 255);
    color: rgb(46, 46, 46);
    /* text-shadow: 0 0 10px rgb(67,149,255); */
    padding: 0;
    border-radius: 30px;
    box-shadow: 0 0 10px 0 rgba(67,149,255,0.3), 0 5px 15px 0 rgba(155, 154, 154, 0.1);
    transition: all 1s;
    opacity: 0;
    z-index: 5;
    /* font-weight: bolder; */
    letter-spacing: 0.1em;
}

.search-div input:hover {
    cursor: pointer;
}

.search-div input:focus {
    width: 200px;
    padding: 0 0 0 20px;
    opacity: 1;
    cursor: text;
}

.search-div input:focus~.search {
    right: -405px;
    background: rgba(9, 111, 245, 0.63);
    z-index: 6;
}

.search-div input:focus~.search::before {
    top: 0;
    left: 0;
    width: 25px;
}

.search-div input:focus~.search::after {
    top: 0;
    left: 0;
    width: 25px;
    height: 2px;
    border: none;
    background: white;
    border-radius: 0%;
    transform: rotate(-45deg);
}

.search-div input::placeholder {
    color: white;
    opacity: 0.5;
    font-weight: bolder;
}
</style>